﻿@using System.Diagnostics
@model XStudio.Framework.Util.TreeData
@{
    List<XStudio.Framework.Util.TreeData> nochilds = null;
    if (Model != null && Model.children != null)
    {
        nochilds = Model.children.FindAll(t => t.children == null || t.children.Count == 0);
    }
    List<XStudio.Framework.Util.TreeData> haschilds = null;
    if (Model != null && Model.children != null)
    {
        haschilds = Model.children.FindAll(t => t.children != null && t.children.Count > 0);
    }
    var r = new Random().Next(10000, 99999);
    var mapping = new string[] { "", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth" };
}
@if (nochilds != null && nochilds.Count > 0)
{
    <p class="ct" style="display: block; padding-left: 0px;" onclick="PartTree.ChildNodeClick(this)">
        <input type="hidden" 
            name=""  value="@Model.id" />
        @foreach (var treeData in nochilds)
        { <span style="white-space: nowrap;" class="nowrap">
            <input type="checkbox" value="@treeData.id" @(treeData.Checked ? "checked='checked'" : "") id="@string.Format("part_{0}_{1}", treeData.id, r)" name="part" />
            <label for="@string.Format("part_{0}_{1}", treeData.id, r)">@treeData.text</label>
        </span>}
    </p>
}
@if (haschilds != null && haschilds.Count > 0)
{
    foreach (var treeData in haschilds)
    {
    <h5 class="tg-left @mapping[treeData.level] no-warp tgd-l " level="@treeData.level"  onclick="PartTree.TitleClick(this)">
        <a class="btn-checknone" selectemode="0" href="javascript:void(0)" onclick="PartTree.LinkNodeClick(this)">
            @treeData.text</a> <span style="display: none">
                <input value="@treeData.id"  @(treeData.Checked ? "checked='checked'" : "")   type="checkbox" name="part" /></span>
    </h5>

    
        Html.RenderPartial("PartTreeItem", treeData);
    }
}